package com.wswy.wzcx.jpush;

import android.content.Context;
import com.wswy.wzcx.AppContext;


public class PushChannel {

  private static NotificationHandler sPushHandler;
  private static PushTagManager sPushTagManager;

  /**
   * 推送类型--极光推送
   */
  public static final int TYPE_JPUSH = 1;

  /**
   * 指定推送类型
   */
  private static int sPushType = TYPE_JPUSH; //

  private static boolean sDEBUG = false;

  public static void init(Context context,boolean debug){
    sDEBUG = debug;
    //此处分辨不同平台
    if(sPushHandler == null){
      sPushHandler = createHandler(context);
    }

    getPushTagManager();
  }


  public static int getPushType() {
    return sPushType;
  }

  public static String getPushTypeText(){
    String ret="";
    switch (sPushType){
      case TYPE_JPUSH:
        ret = "jpush";
        break;
    }
    return ret;
  }

  public static NotificationHandler getHandler(){
    if(sPushHandler == null){
      synchronized (PushChannel.class){
        if(sPushHandler == null){
          sPushHandler = createHandler(AppContext.getContext());
        }
      }
    }
    return sPushHandler;
  }

  public static PushTagManager getPushTagManager(){
    if(sPushTagManager == null){
      synchronized (PushChannel.class){
        if(sPushTagManager == null){
          sPushTagManager = new PushTagManager(getHandler());
        }
      }
    }
    return sPushTagManager;
  }


  public static void switchPush(boolean status){
    getHandler().switchPush(status);
  }

  private static NotificationHandler createHandler(Context context){
    return new NotificationHandler(context,getPushType(),sDEBUG);
  }

}
